<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('账单管理列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li class="select-time">
                            <label>消费时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginTimestamp]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endTimestamp]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="custom:bill:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="custom:bill:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">

    var editFlag = [[${@permission.hasPermi('custom:bill:edit')}]];
    var removeFlag = [[${@permission.hasPermi('custom:bill:remove')}]];
    var customerTypeDatas = [[${@dict.getType('user_info')}]];
    var paymentMethodDatas = [[${@dict.getType('mode_payment')}]];
    var descriptionDatas = [[${@dict.getType('commodity_management')}]];
    var prefix = ctx + "custom/bill";
    var prefixMember = ctx + "custom/member";
    var memberData ;
    $(function () {
        //拿到所有
        $.operate.post(prefixMember + "/list", null, function (rs) {
            //关闭加载
            $.modal.closeLoading();
            memberData = rs.rows
        });

        var options = {
            url: prefix + "/list",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "账单管理",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '账单编码',
                    visible: false
                },
                {
                    field: 'customerId',
                    title: '顾客姓名',
                    formatter: function (value, row, index) {
                        for (var i = 0; i < memberData.length; i++) {
                            if (memberData[i].id === value){
                                return memberData[i].name
                            }
                        }
                    }
                },

                {
                    field: 'customerType',
                    title: '顾客类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(customerTypeDatas, value);
                    }
                },
                // {
                //     field: 'amount',
                //     title: '消费金额'
                // },
                {
                    field: 'paymentMethod',
                    title: '支付方式',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(paymentMethodDatas, value);
                    }
                },
                {
                    field: 'createTime',
                    title: '消费时间戳'
                },
                {
                    field: 'description',
                    title: '订单备注',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabels(descriptionDatas, value);
                    }
                },
            ]
        };
        $.table.init(options);
    });

</script>
</body>
</html>